package com.horizon.kafka.v010;

import java.util.Map;

import org.apache.kafka.clients.producer.Partitioner;
import org.apache.kafka.common.Cluster;


/**
 * @author Administrator
 *
 */
public class SimplePartitioner implements Partitioner {

    public SimplePartitioner() {
    }

    @Override
    public void configure(Map<String, ?> configs) {
    }

    @Override
    public int partition(String topic, Object key, byte[] keyBytes, Object value, byte[] valueBytes, Cluster cluster) {
    	if(Integer.parseInt(key.toString())%2 == 1)
    		return 0;
    	else 
    		return 1;
    }

    @Override
    public void close() {
    }
    

}
